<?php 
session_start();
require_once('../includes/user.php');
$user=new User();
 ?>
 <script language="javascript" src="js/jquery.autocomplete.js"></script>
<link href="css/autocomplete.css" rel="stylesheet" type="text/css" />
 <table width="398" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td><div class="Innerheading">Point Request</div></td>
  </tr>
  <tr>
    <td><div class="InnerDarkbox">
      <table width="100%" height="72" border="0" align="center" cellpadding="0" cellspacing="0">
        <tr>
          <td width="143">&nbsp;</td>
          <td width="10">&nbsp;</td>
          <td width="245">&nbsp;</td>
        </tr>
        <tr>
          <td align="right" class="head">Request for :</td>
          <td>&nbsp;</td>
          <td><select name="request_for" class="FormTextFeild" id="request_for">
            <option value="1" selected>Academics</option>
            <option value="2">Extra curricular</option>
          </select>          </td>
        </tr>
        <tr>
          <td class="head">&nbsp;</td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
        </tr>
        <tr>
          <td align="right" class="head"><span id="select_mode_text">Select Exam</span> :</td>
          <td>&nbsp;</td>
          <td><select name="select_mode" class="FormTextFeild" id="select_mode">
            <option value="11" selected>University Exam</option>
            <option value="12">Internal Exam</option>
            </select></td>
        </tr>
      </table>
      <table id="academic_table" width="100%" height="86" border="0" align="center" cellpadding="0" cellspacing="0">

        <tr>
          <td height="20" align="right" class="head">&nbsp;</td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
        </tr>
        <tr>
          <td height="22" align="right" class="head"><span id="sub_text">Select Semester</span> :</td>
          <td>&nbsp;</td>
          <td><select name="test" class="FormTextFeild" id="test">
          		<?php
				$pro=$user->getUserProfile($_SESSION['id']);
				 if($pro['year']==2)
				 {
				?>
            <option value="2">2</option>
            <option value="3">3</option>
                 <?Php
				 }
				 else if($pro['year']==3)
				 { 
				 ?>
                 <option value="4">4</option>
            	<option value="5">5</option>
                 <?php
				 }
				 else if($pro['year']==4)
				 {
				 	?>                 
                <option value="6">6</option>
                <option value="7">7</option>
                    <?php
				 }
				 ?>
          </select>
          </td>
        </tr>
        <tr>
          <td height="20" align="right" class="head">&nbsp;</td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
        </tr>
        <tr>
          <td width="139" height="22" align="right" class="head">Percentage :</td>
          <td width="10">&nbsp;</td>
          <td width="251"><input name="percentage" type="text" class="FormTextFeild" id="percentage" maxlength="5"></td>
        </tr>
      </table>
      <table id="activities_table" width="100%" height="170" border="0" align="center" cellpadding="0" cellspacing="0" style="display:none;">
        <tr>
          <td height="20" align="right" class="head">&nbsp;</td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
        </tr>
        <tr>
          <td height="22" align="right" class="head"><span id="event_txt">Event , Dept</span> :</td>
          <td>&nbsp;</td>
          <td><input name="college" type="text" class="FormTextFeild" id="college"></td>
        </tr>
        <tr>
          <td height="20" align="right" class="head">&nbsp;</td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
        </tr>
        <tr>
          <td height="20" align="right" class="head">Competition :</td>
          <td>&nbsp;</td>
          <td><input name="competition" type="text" class="FormTextFeild" id="competition"></td>
        </tr>
        <tr>
          <td height="22" align="right" class="head">&nbsp;</td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
        </tr>
        <tr>
          <td height="22" align="right" class="head">Prize level :</td>
          <td>&nbsp;</td>
          <td><select name="prize_level" class="FormTextFeild" id="prize_level">
            <option value="1">First</option>
            <option value="2">Second</option>
            <option value="3">Third</option>
          </select></td>
        </tr>
        <tr>
          <td height="22" align="right" class="head">&nbsp;</td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
        </tr>
        <tr>
          <td width="126" height="22" align="right" class="head">Date :</td>
          <td width="10">&nbsp;</td>
          <td width="228"><input name="date" type="text" class="FormTextFeild" id="date" onFocus="popcal('dt_cal','date')"><div id ="dt_cal"  style="position:absolute; z-index:1000" ></td>
        </tr>
      </table>
      <table id="academic_table2" width="100%" height="60" border="0" align="center" cellpadding="0" cellspacing="0">
        
        <tr>
          <td height="30" colspan="3" align="left" class="head">
          <div id="pt_req_status" class="strykerError"></div></td>
          </tr>

        <tr>
          <td width="126" height="20" align="right" class="head">&nbsp;</td>
          <td width="10">&nbsp;</td>
          <td width="228"><input type="image" src="img/buttons/submit.gif" onclick="update_pt_request()" /></td>
        </tr>
      </table>
    </div></td>
  </tr>
</table>
<script>
	$('#request_for').change(function()
	{
		$('#pt_req_status').hide();
		if($('#request_for').val()==1)
		{
			//academics
			$('#select_mode').html('<option value="11" selected>University Exam</option><option value="12">Internal Exam</option>');
			$('#select_mode_text').html('Select Exam');
			$('#activities_table').hide();
			$('#academic_table').show();
			if($('#select_mode').val()==11)
			{
				$('#sub_text').html('Select Semester');
				<?php
					$pro=$user->getUserProfile($_SESSION['id']);
					 if($pro['year']==2)
					 {
					?>
				$('#test').html('<option value="2">2</option><option value="3">3</option>');
					 <?Php
					 }
					 else if($pro['year']==3)
					 { 
					 ?>
				$('#test').html('<option value="4">4</option><option value="5">5</option>');
					 <?php
					 }
					 else if($pro['year']==4)
					 {
					?>                 
				$('#test').html('<option value="6">6</option><option value="7">7</option>');
                    <?php
				 	}
				 ?>
			}
		}
		else
		{
			$('#select_mode').html('<option value="21" selected>Intra college</option><option value="22">Inter College</option>');
			$('#academic_table').hide();
			$('#activities_table').show();
			$('#select_mode_text').html('Select Activity');
			$('#prize_level').html('<option value="1" selected="selected">First</option><option value="2">Second</option><option value="3">Third</option>');
			$('#event_txt').html('Event , Dept');
			updateCompSuggestions();
			updateCollDeptSuggestions();
		}
	});
	$('#percentage').keypress(function(e){
		if( e.which!=8 && e.which!=0 && e.which!=46 && (e.which<48 || e.which>57))
  		{
    		return false;
  		}
	});
	$('#select_mode').change(function(){
	$('#pt_req_status').hide();
		if($('#select_mode').val()==11)
		{
			$('#sub_text').html('Select Semester');
			<?php
				$pro=$user->getUserProfile($_SESSION['id']);
				 if($pro['year']==2)
				 {
				?>
			$('#test').html('<option value="2">2</option><option value="3">3</option>');
                 <?Php
				 }
				 else if($pro['year']==3)
				 { 
				 ?>
            $('#test').html('<option value="4">4</option><option value="5">5</option>');
                 <?php
				 }
				 else if($pro['year']==4)
				 {
				 	?>                 
           	$('#test').html('<option value="6">6</option><option value="7">7</option>');
                    <?php
				 }
				 ?>
		}
		else if($('#select_mode').val()==12)
		{
			$('#sub_text').html('Select Test');
			$('#test').html('<option value="1">Assesment I</option><option value="2">Assesment II</option><option value="3">Assesment III</option>');
		}
		else if($('#select_mode').val()==21)
		{
		$('#prize_level').html('<option value="1" selected="selected">First</option><option value="2">Second</option><option value="3">Third</option>');
		$('#event_txt').html('Event , Dept');
		updateCollDeptSuggestions();
		}
		else if($('#select_mode').val()==22)
		{
			$('#prize_level').html('<option value="0" selected>Participation</option><option value="1">First</option><option value="2">Second</option><option value="3">Third</option>');
			$('#event_txt').html('Event , College');
			updateCollEventSuggestions()
		}
	});
	function updateCompSuggestions()
	{
		//get competitions name
		$.post("pt_request/suggestions.php",{type:"comp"},function(comp){
			comp = comp.slice(0, -2);
			comp = comp.split("::");
			$('#competition').flushCache();
			$('#competition').autocomplete(comp);
		});
	}
	function updateCollDeptSuggestions()
	{
		//get event,dept name
		$.post("pt_request/suggestions.php",{type:"dept"},function(dept){
			dept = dept.slice(0, -2);
			dept = dept.split("::");
			$('#college').flushCache();
			$('#college').autocomplete(dept);
		});
	}
	function updateCollEventSuggestions()
	{
		//get event,dept name
		$.post("pt_request/suggestions.php",{type:"college"},function(eve){
			eve = eve.slice(0, -2);
			eve = eve.split("::");
			$('#college').flushCache();
			$('#college').autocomplete(eve);
		});
	}
</script>